<template>
	<view>
		<view class="project" v-for="(item,i) in projectList" :key="i" @click="gotoDetail(item)">
			<view class="ptu">
				<image :src="item.address"></image>
			</view>
			<view class="info">
			<text>{{item.pname}}</text>
			<text>价格：{{item.price}}/次</text>
			</view>
		</view>
		<view class="project" v-for="(item,i) in projectList1" :key="i" @click="gotoDetail(item)">
			<view class="ptu">
				<image :src="item.address"></image>
			</view>
			<view class="info">
			<text>{{item.pname}}</text>
			<text>价格：{{item.price}}/次</text>
			</view>
		</view>
		<view class="project" v-for="(item,i) in projectList2" :key="i" @click="gotoDetail(item)">
			<view class="ptu">
				<image :src="item.address"></image>
			</view>
			<view class="info">
			<text>{{item.pname}}</text>
			<text>价格：{{item.price}}/次</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goods_from:'',
				goods_id:'',
				projectList:[],
				projectList1:[],
				projectList2:[],
			};
		},
		onLoad(options) {
			this.goods_id=options.id
			this.goods_from=options.goods_from
			if(options.id==11)
				this.getProjectList();
				if(options.id==22){
					this.getProjectList1();
					}
					if(options.id==33){
						this.getProjectList2();
						}
		},
		methods:{
			async getProjectList(){
			const  res=await uni.$http.get('http://localhost:8020/project')
			if(res.statusCode!=200){
				return uni.$showMsg()
			}
			this.projectList= res.data
			uni.$showMsg('数据请求成功')
			},
			async getProjectList1(){
			const  res=await uni.$http.get('http://localhost:8020/project1')
			if(res.statusCode!=200){
				return uni.$showMsg()
			}
			this.projectList1= res.data
			uni.$showMsg('数据请求成功')
			},
			async getProjectList2(){
			const  res=await uni.$http.get('http://localhost:8020/project2')
			if(res.statusCode!=200){
				return uni.$showMsg()
			}
			this.projectList2= res.data
			uni.$showMsg('数据请求成功')
			},
			gotoDetail(item){
				uni.navigateTo({
					url:'/subpage/detail/detail?goods_name='+item.pname+'&price='+item.price+'&goods_id='+item.id+'&goods_from='+this.goods_from
				})
			}
		},
		onReady() {
			
		}
	}
</script>

<style lang="scss">
.project{
	display: flex;
	padding: 15rpx;
	border: 1rpx solid #efefef;
	border-radius: 8%;
	margin: 15rpx;
}
.ptu image{
	width: 250rpx;
	height: 250rpx;
	display: block;
	margin-right: 15rpx;
}
.info{
	display: flex;
	flex-direction: column;//纵向布局
	justify-content: space-around;//纵向上分散对齐
	font-size: 50rpx;
}
</style>
